#include "tcpServer.hpp"

// #include "daemon.hpp"   // 把 tcpServer 进程变成守护进程

#include <memory>
#include <cstdlib>

using namespace Server;
using namespace std;

// 使用手册
static void Usage(std::string proc){
    std::cerr << "\nUsage:\n\t" << proc << "serverport\n\n" << std::endl;
}

// ./tcpServer serverport [serverip]
int main(int argc, char* args[]){
    // serverip 就先不传递了，直接设置进去了
    if(argc != 2){
        Usage(args[0]);
        exit(USAGE_ERROR);
    }
    uint16_t serverport = atoi(args[1]);

    std::unique_ptr<tcpServer> tser(new tcpServer(serverport));
    tser->initServer();

    // tser->daemonSelf();

    tser->start();

    return 0;
}